/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {number[]}
 */
var nextLargerNodes = function (head) {
  let nodeLeft = new ListNode(), nodeRight = new ListNode(), res = []

  nodeLeft = head
  nodeRight = nodeLeft.next
  while (nodeLeft) {

    if (nodeRight) {
      if (nodeRight.val > nodeLeft.val) {
        res.push(nodeRight.val)
        nodeLeft = nodeLeft.next
        nodeRight = nodeLeft.next
      }else{
        nodeRight=nodeRight.next
      }

    }
    else {
      res.push(0)
    }
  }

  return arr
};